package com.gang.application;

import javax.sql.DataSource;

import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.Configuration;
import org.springframework.remoting.caucho.HessianProxyFactoryBean;
import org.springframework.stereotype.Controller;

import com.gang.ssm.bos.system.service.CustomerService;

@Configuration
@ComponentScan(basePackages = "com.gang.ssm.bos", 
			excludeFilters={@Filter(value=Controller.class)})
public class BosApplication {
	
	@Bean
	public HessianProxyFactoryBean customerService() {
		HessianProxyFactoryBean hessianProxyFactoryBean = 
				new HessianProxyFactoryBean();
		hessianProxyFactoryBean.setServiceInterface(CustomerService.class);
		hessianProxyFactoryBean.setServiceUrl("http://localhost:8080/remoting/customer");
		
		return hessianProxyFactoryBean;
	}
	
	@Bean(name = "dataSource")
	@ConfigurationProperties(prefix = "c3p0")
	public DataSource dataSource() {
		return DataSourceBuilder.create().type(com.mchange.v2.c3p0.ComboPooledDataSource.class).build();
	}
	
}
